import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'Index',
    component: ()=>import(/* webpackChunkName: "homeIndex" */ '../views/index.vue'),
    children:[
      // 子路由
      {
        path:'/home',
        name:"home",
        component:()=>import (/* webpackChunkName: "home" */ '../components/home')
      },
      {
        path:'/goodscategory',
        name:"goodscategory",
        component:()=>import (/* webpackChunkName: "goodscategory" */ '../components/goodscategory')
      },
      {
        path:'/user',
        name:"user",
        component:()=>import (/* webpackChunkName: "user" */ '../components/user')
      }
    ]
  },
  {
    path:'/cart',
    name:'cart',
    component:()=>import(/* webpackChunkName: "cart" */ '../components/cart')
  },
  {
    path:'/login',
    name:'login',
    component:()=>import(/* webpackChunkName: "login" */ '../views/login')
  },
  {
    path:'/register',
    name:'register',
    component:()=>import(/* webpackChunkName: "register" */ '../views/register')
  },
  {
    path:'/order',
    name:'order',
    component:()=>import(/* webpackChunkName: "order" */ '../components/order')
  },
  {
    path:'/goodsInfo/:id',
    name:'goodsInfo',
    component:()=>import(/* webpackChunkName: "goodsInfo" */ '../components/goodsInfo')
  },
  {
    path: '/about',
    name: 'About',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  // linkActiveClass:'current',
  routes
})

export default router
